

public class NaiveMoveReverse implements MoveRule {


	@Override
	public boolean isLegalMove(Board board, Move move, Move.Direction direction) 
	{
//		boolean value = true;
//		
////		if ( !board.getCellType( move.doNewMove( direction.reverse() ) ).isBox() )
////		{
////			throw new RuntimeException("Bug i Olles kod igen!");
////		}
//		
//		Move movePlus = move.doNewMove(direction.reverse());
//		
//		value &= board.getCellType( move ).notWallOrBox();
//		value &= board.getCellType( movePlus ).notWallOrBox();
//		
////		value &= visitable[ movePlus.getX() ][ movePlus.getY() ];
//
//		return value;
		
        switch ( board.getCellType(move) ) 
        {
	        case Wall: 				return false;
	        
	        case Player: throw new RuntimeException("Bug i olles regel:3");
	        case PlayerOnGoalSquare: throw new RuntimeException("Bug i olles regel:4");
//	        case Player: break;
//	        case PlayerOnGoalSquare: break;
	        case GoalSquare: break;
	        case EmptyFloor: break;
	        
	        case Box: return false; 
	        case BoxOnGoal: return false;
	        	        	
	        default: throw new IllegalArgumentException();
        }
        
        Move boxMove = move.doNewMove( direction.reverse() );
        
        if ( !board.getCellType( boxMove ).isPlayer() )
        {
        	throw new RuntimeException("Bug i olles regel:5");
        }
        
//        switch ( board.getCellType(boxMove) ) 
//        {
//	        case Wall: 				return false;
//	        
//	        case Player: throw new RuntimeException("Bug i olles regel:1");
//	        case PlayerOnGoalSquare: throw new RuntimeException("Bug i olles regel:2");
//	        case GoalSquare: break;
//	        case EmptyFloor: break;
//	        
//	        case Box: 				return false;
//	        case BoxOnGoal: 		return false;
//
//	        	
//	        default: throw new IllegalArgumentException();
//        }
        
        return true;
	}

}
